﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class BalanceCenter_AdminInformationAdd : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            if (Shove._Convert.StrToInt(Shove._Web.Utility.GetRequest("ID"), -1) != -1)
            {
                Shove.ControlExt.SetDownListBoxTextFromValue(ddlType, Shove._Web.Utility.GetRequest("ID"));
            }

            BindData();
        }
    }

    #region Web 窗体设计器生成的代码

    protected override void OnLoad(EventArgs e)
    {
        isRequestLogin = true;                                  //是否需要登录
        RequestLoginPage = this.Request.Url.AbsoluteUri;        //获取决对Url
        isAtFramePageLogin = true;                              //是框架页

//       RequestCompetences = Competences.BuildCompetencesList(Competences.EditNews);//页面权限

        base.OnLoad(e);
    }

    #endregion

    private void BindData()
    {
        tbDateTime.Text = System.DateTime.Now.ToString();
    }

    protected void btnAdd_Click(object sender, System.EventArgs e)
    {
        DateTime dt = System.DateTime.Now;
        try
        {
            dt = System.DateTime.Parse(tbDateTime.Text);
        }
        catch
        {
            Shove._Web.JavaScript.Alert(this.Page, "时间格式错误，请输入如“" + dt.ToString() + "”的时间格式。");

            return;
        }

        string Title = tbTitle.Text.Trim();
        if (Title == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入标题。");

            return;
        }

        DAL.Tables.tbl_Information Information = new DAL.Tables.tbl_Information();

        Information.DateTime.Value = dt;
        Information.Title.Value = Title;
        Information.Content.Value = Shove._String.Compress(tbContent.Value);
        Information.isShow.Value = cbisShow.Checked;
        Information.Type.Value = Shove._Convert.StrToInt(ddlType.SelectedValue, 1);

        if (Information.Insert() < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "信息添加失败。");

            return;
        }

        this.Response.Redirect("AdminInformation.aspx", true);
    }
}